package com.xyoto.community.controller;

import com.xyoto.community.aspect.annotation.RequiresLogin;
import com.xyoto.community.dto.SaveGuestBookDTO;
import com.xyoto.community.service.GuestBookService;
import com.xyoto.community.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/guest")
@Api(value = "留言板（前台）", tags = "留言板（前台）")
public class GuestBookController {

    @Autowired
    private GuestBookService guestBookService;

    @RequiresLogin
    @ApiOperation(value = "新增留言（前台）", notes = "新增留言（前台）")
    @PostMapping("saveGuestBook")
    public Result saveGuestBook(@RequestBody @Validated SaveGuestBookDTO saveGuestBookDTO){
        return guestBookService.saveGuestBook(saveGuestBookDTO);
    }

    @ApiOperation("获取留言")
    @GetMapping("getGuestBook")
    public Result saveGuestBook(){
        return guestBookService.getGuestBookList();
    }


}
